/**
 * Created by BaiYJ on 2017/4/21.
 */


var editor; // use a global for the submit and return data rendering
$(document).ready(function () {


    editor = new $.fn.dataTable.Editor({
        ajax: {
            create: {
                type: 'POST',
                url: '/commis/api/personCc/create'
            },
            edit: {
                type: 'PUT',
                url: '/commis/api/personCc/edit?id=_id_'
            },
            remove: {
                type: 'DELETE',
                url: '/commis/api/personCc/remove?id=_id_'
            }
        },
        i18n: {
            create: {
                title: "新增记录",
                submit: "添加"
            },
            edit: {
                title: "修改记录",
                submit: "修改",
                confirm: "您确定要修改这 %d 条记录吗?"
            },
            remove: {
                title: "删除记录",
                submit: "删除",
                confirm: "您确定要删除这 %d 条记录吗?"
            }
        },
        idSrc: 'ccId',
        table: "#dataTable",
        fields: [
            {
                label: "分档名称:",
                name: "ccName"
            },
            {
                label: "分档工资:",
                name: "ccWage"
            }
        ]
    });


    var table = $('#dataTable').DataTable({

        dom: "Bfrtip",
        ajax: "/commis/api/personCc/pageDatatables",


        serverSide: true,
        processing: true,
        lengthChange: false,//是否允许用户改变表格每页显示的记录数
        ordering: false,//是否允许用户排序
        paging: true,//是否分页
        pagingType: "full_numbers",//除首页、上一页、下一页、末页四个按钮还有页数按钮
        searching: false,//是否开始本地搜索
        stateSave: false,//刷新时是否保存状态
        autoWidth: true,//自动计算宽度
        language: {
            emptyTable: "没有数据",
            search: "搜索:",
            paginate: {
                first: "首页",
                previous: "上一页",
                next: "下一页",
                last: "尾页"

            },
            select: {
                rows: {
                    _: "选中 %d 行",
                    1: "选中 1 行"
                }/*,
                 columns: "选中 %d 列"*/
            },
            lengthMenu: "每页 _MENU_ 条记录",
            zeroRecords: "没有找到记录",
            info: "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )，共 _TOTAL_ 项",
            infoEmpty: "无记录",
            infoFiltered: "(从 _MAX_ 条记录过滤)"
        },
        columns: [
            {
                data: 'ccName', defaultContent: ""
            },{
                data: 'ccWage', defaultContent: ""
            }], select: true,
        buttons: [
            {extend: "create", editor: editor, text: "添加", className: 'btn btn-primary'},
            {extend: "edit", editor: editor, text: "修改", className: 'btn btn-primary'},
            {extend: "remove", editor: editor, text: "删除", className: 'btn btn-danger'}
        ]

    });


    $('#search').on('click', function () {

        var url = "/commis/api/personCc/pageDatatables?1=1"
/*
        if ($("#comm").val() != "") {
            var houseAdd = $('#houseAdd').val();
            url = url + "&houseAdd=" + houseAdd;
        }*/



        table.ajax.url(url).load();
    });





})
//设置框架
$(function () {
    $("#page_style").frame({
        float: 'left',
        menu_nav: '.Quick_operation',
        color_btn: '.skin_select',
        Sellerber_menu: '.list_content',
        Sellerber_header: '.Sellerber_header',
    });
});
$("#iframe_box").niceScroll({
    cursorcolor: "#888888",
    cursoropacitymax: 1,
    touchbehavior: false,
    cursorwidth: "5px",
    cursorborder: "0",
    cursorborderradius: "5px"
});
/*********************/
require.config({
    paths: {
        echarts: './js/dist'
    }
});